import os
import json

def storeNodes(dic, id_clusters):
    print("storeNodes started")
    theID = id_clusters.split('_')[0]
    clusters = id_clusters.split('_')[1]
    os.system('mkdir json/nodeInfos/' + theID)
    os.system('mkdir json/nodeInfos/' + theID + '/' + clusters)
    for cluster_id in list(dic['cluster']):
        os.system('mkdir json/nodeInfos/' + theID + '/' + clusters + '/' + cluster_id)
        nodes = dic['cluster'][cluster_id]['nodes']
        for node in nodes:
            f = open('json/nodeInfos/' + theID + '/' + clusters + '/' + cluster_id + '/' + node['id'] + '.json', 'w')
            str2write = json.dumps(node)
            f.write(str2write)
            f.close()
    print("storeNodes finished")
